<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>文本类指令</title>
  </head>
  <body>
    <div id="app">
      <!-- 双大括号是不会解析标签的 -->
      <!-- <div>{{ context }}</div> -->

      <!-- v-html可以将内容解析成标签 -->
      <!-- v-html相当于innerHTML -->
      <!-- v-html只能对你信得过的内容使用 -->
      <!-- 滥用可能会造成xss攻击 -->
      <div v-html="context"></div>

      <!-- v-text不会解析html标签, 效果和双大括号差不多 -->
      <!-- v-text相当于innerText -->
      <div v-text="context"></div>

      <!-- v-pre该指令的标签内部的语法不会被vue解析 -->
      <!-- <div v-pre>{{ context }}</div> -->
      <div v-pre>{{ context }}</div>
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      const { createApp } = Vue;

      createApp({
        data() {
          return {
            context: "<h1>文本类指令</h1>",
          };
        },
      }).mount("#app");
    </script>
  </body>
</html>
